package com.vitabuybuy.tv.adaptebinding

import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide


object ImageAdapter {

    @BindingAdapter(value = ["nomalUrl", "placeholder"], requireAll = false)
    @JvmStatic
    fun setNomalImageUrl(imageView: ImageView, nomalUrl: String?, placeholder: Drawable?) {
        Glide.with(imageView.context).asBitmap().load(nomalUrl).centerCrop().placeholder(placeholder).into(imageView)
    }

    @BindingAdapter(value = ["avatarUrl", "placeholder"], requireAll = false)
    @JvmStatic
    fun setCircleImageUrl(imageView: ImageView, avatarUrl: String?, placeholder: Drawable?) {
        Glide.with(imageView.context).asBitmap().load(avatarUrl).circleCrop().placeholder(placeholder).into(imageView)
    }
}